<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="../include/base.jsp" %>
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">	
	<title>CRM-contact-addcontact</title>
	<meta charset="UTF-8">
	<%@ include file="../include/head.jsp" %>
</head>

<body class="crm">
	
<jsp:include page="../include/top.jsp">
	<jsp:param value="task" name="tag"/>
</jsp:include>


<div class="container-fluid">
	<div class="row-fluid">
		<div class="span8">
		<div class="well screen">
			<div class="page-header header">
							
				<div class="right-links">
					<a href="${basePath }/task/list" class="current">待办任务</a> |
					<a href="${basePath }/task/list?collection=completed">已完成的任务</a>
						| <a href="${basePath }/task/list?collection=assigned">我分配的任务</a>
				</div>待办任务
			</div>
			<div class="live_search_spinner" behavior="spinner" id="parties_loading">
			  <div class="liner">
			    <h3>处理中...</h3>
			    <img src="${basePath }/img/indicator.gif" alt="WorkXP">
			  </div>
			</div>
			<div class="main" id="main">
						
				<div id="task_filter">分配给 
					<select id="user_id" name="user_id" onchange="">
						<option value="">我</option>
						<c:forEach items="${userList }" var="user">
							<option value="${user.id }">${user.username }</option>
						</c:forEach>
					</select>分类为
					<select id="filter_task_category_id" name="filter_task_category_id" onchange="">
						<option value="">所有</option>
						<c:forEach items="${tasktypeList }" var="tasktype">
							<option value="${tasktype.id }">${tasktype.type }</option>
						</c:forEach>
					</select>
				</div>
	
				<div id="upcoming_tasks">
					<div id="screen_body">
					<div class="tasks overdue">
					
					<!-- 待办的 -->
					<c:if test="${param.collection == null }">
					
						<c:if test="${fn:length(pastList) != 0 }">
							<legend>已过期</legend>
							<c:forEach items="${pastList }" var="p">
							<div id="task_${p.id }" class="task checkbox">
								<span class="task_hover">
									<div class="task_actions">
										<a href="${basePath }/task/del?id=${p.id}" id="${p.id }" onclick="deltask(this)" class="icon icon-trash" data-confirm="您确定要删除这个任务吗？" data-method="delete" data-remote="true" rel="nofollow" title="删除这个任务"></a>
										<a href="${basePath }/task/tasktype" class="edit" data-remote="true">编辑</a>
									</div>
									
									<input id="task_done_${p.id }" name="task_done" onclick="donetask(this)" type="checkbox" value="${p.id }" alt="${p.user.username }">
									<c:if test="${p.tasktype.type != null }">
										<span style="background:#${p.tasktype.color};" class="label">${p.tasktype.type }</span>
									</c:if>
									${p.user.username }:${p.title }
								</span>
							</div>
							</c:forEach>
						</c:if>
						<c:if test="${fn:length(todayList) != 0 }">
							<legend>今日任务</legend>
							<c:forEach items="${todayList }" var="td">
							<div id="task_${td.id }" class="task checkbox">
								<span class="task_hover">
									<div class="task_actions">
										<a href="${basePath }/task/del?id=${td.id}" id="${td.id }" onclick="deltask(this)" class="icon icon-trash" data-confirm="您确定要删除这个任务吗？" data-method="delete" data-remote="true" rel="nofollow" title="删除这个任务"></a>
										<a href="${basePath }/task/tasktype" class="edit" data-remote="true">编辑</a>
									</div>
									
									<input id="task_done_${td.id }" name="task_done" onclick="donetask(this)" type="checkbox" value="${td.id }" alt="${td.user.username }">
									<c:if test="${td.tasktype.type != null }">
										<span style="background:#${td.tasktype.color};" class="label">${td.tasktype.type }</span>
									</c:if>
									${td.user.username }:${td.title }
								</span>
							</div>
							</c:forEach>
						</c:if>
						<c:if test="${fn:length(tomorrowList) != 0 }">
							<legend>明日任务</legend>
							<c:forEach items="${tomorrowList }" var="t">
							<div id="task_${t.id }" class="task checkbox">
								<span class="task_hover">
									<div class="task_actions">
										<a href="${basePath }/task/del?id=${t.id}" id="${t.id }" onclick="deltask(this)" class="icon icon-trash" data-confirm="您确定要删除这个任务吗？" data-method="delete" data-remote="true" rel="nofollow" title="删除这个任务"></a>
										<a href="${basePath }/task/tasktype" class="edit" data-remote="true">编辑</a>
									</div>
									
									<input id="task_done_${t.id }" name="task_done" onclick="donetask(this)" type="checkbox" value="${t.id }" alt="${t.user.username }">
									<c:if test="${t.tasktype.type != null }">
										<span style="background:#${t.tasktype.color};" class="label">${t.tasktype.type }</span>
									</c:if>
									${t.user.username }:${t.title }
								</span>
							</div>
							</c:forEach>
						</c:if>
						<c:if test="${fn:length(laterList) != 0 }">
							<legend>明日以后任务</legend>
							<c:forEach items="${laterList }" var="la">
							<div id="task_${la.id }" class="task checkbox">
								<span class="task_hover">
									<div class="task_actions">
										<a href="${basePath }/task/del?id=${la.id}" id="${la.id }" onclick="deltask(this)" class="icon icon-trash" data-confirm="您确定要删除这个任务吗？" data-method="delete" data-remote="true" rel="nofollow" title="删除这个任务"></a>
										<a href="${basePath }/task/edittask" class="edit" data-remote="true">编辑</a>
									</div>
									
									<input id="task_done_${la.id }" name="task_done" onclick="donetask(this)" type="checkbox" value="${la.id }" alt="${la.user.username }">
									<c:if test="${t.tasktype.type != null }">
										<span style="background:#${t.tasktype.color};" class="label">${la.tasktype.type }</span>
									</c:if>
									${la.user.username }:${la.title }
								</span>
							</div>
							</c:forEach>
						</c:if>
						<c:if test="${fn:length(taskList) == 0 }" var="task">
							<div id="upcoming_tasks">
								<div class="alert alert-info"> 没有待办任务，或者已经完成了所有任务！ </div>
							</div>
						</c:if>
					</c:if>
					
					
					<!-- 分配给我的 -->
					<c:if test="${param.collection == 'assigned' }">
						<c:if test="${fn:length(pastList) != 0 }">
							<legend>已过期</legend>
							<c:forEach items="${pastList }" var="p">
							<div id="task_${p.id }" class="task checkbox">
								<span class="task_hover">
									<div class="task_actions">
										<a href="${basePath }/task/del?id=${p.id}" id="${p.id }" onclick="deltask(this)" class="icon icon-trash" data-confirm="您确定要删除这个任务吗？" data-method="delete" data-remote="true" rel="nofollow" title="删除这个任务"></a>
										<a href="${basePath }/task/edittask" class="edit" data-remote="true">编辑</a>
									</div>
									
									<input id="task_done_${p.id }" name="task_done" onclick="donetask(this)" type="checkbox" value="${p.id }" alt="${p.user.username }">
									<c:if test="${p.tasktype.type != null }">
										<span style="background:#${p.tasktype.color};" class="label">${p.tasktype.type }</span>
									</c:if>
									${p.user.username }:${p.title }
								</span>
							</div>
							</c:forEach>
						</c:if>
						<c:if test="${fn:length(todayList) != 0 }">
							<legend>今日任务</legend>
							<c:forEach items="${todayList }" var="td">
							<div id="task_${td.id }" class="task checkbox">
								<span class="task_hover">
									<div class="task_actions">
										<a href="${basePath }/task/del?id=${td.id}" id="${td.id }" onclick="deltask(this)" class="icon icon-trash" data-confirm="您确定要删除这个任务吗？" data-method="delete" data-remote="true" rel="nofollow" title="删除这个任务"></a>
										<a href="${basePath }/task/tasktype" class="edit" data-remote="true">编辑</a>
									</div>
									
									<input id="task_done_${td.id }" name="task_done" onclick="donetask(this)" type="checkbox" value="${td.id }" alt="${td.user.username }">
									<c:if test="${td.tasktype.type != null }">
										<span style="background:#${td.tasktype.color};" class="label">${td.tasktype.type }</span>
									</c:if>
									${td.user.username }:${td.title }
								</span>
							</div>
							</c:forEach>
						</c:if>
						<c:if test="${fn:length(tomorrowList) != 0 }">
							<legend>明日任务</legend>
							<c:forEach items="${tomorrowList }" var="t">
							<div id="task_${t.id }" class="task checkbox">
								<span class="task_hover">
									<div class="task_actions">
										<a href="${basePath }/task/del?id=${t.id}" id="${t.id }" onclick="deltask(this)" class="icon icon-trash" data-confirm="您确定要删除这个任务吗？" data-method="delete" data-remote="true" rel="nofollow" title="删除这个任务"></a>
										<a href="${basePath }/task/tasktype" class="edit" data-remote="true">编辑</a>
									</div>
									
									<input id="task_done_${t.id }" name="task_done" onclick="donetask(this)" type="checkbox" value="${t.id }" alt="${t.user.username }">
									<c:if test="${t.tasktype.type != null }">
										<span style="background:#${t.tasktype.color};" class="label">${t.tasktype.type }</span>
									</c:if>
									${t.user.username }:${t.title }
								</span>
							</div>
							</c:forEach>
						</c:if>
						<c:if test="${fn:length(laterList) != 0 }">
							<legend>明日以后任务</legend>
							<c:forEach items="${laterList }" var="la">
							<div id="task_${la.id }" class="task checkbox">
								<span class="task_hover">
									<div class="task_actions">
										<a href="${basePath }/task/del?id=${la.id}" id="${la.id }" onclick="deltask(this)" class="icon icon-trash" data-confirm="您确定要删除这个任务吗？" data-method="delete" data-remote="true" rel="nofollow" title="删除这个任务"></a>
										<a href="${basePath }/task/tasktype" class="edit" data-remote="true">编辑</a>
									</div>
									
									<input id="task_done_${la.id }" name="task_done" onclick="donetask(this)" type="checkbox" value="${la.id }" alt="${la.user.username }">
									<c:if test="${la.tasktype.type != null }">
										<span style="background:#${t.tasktype.color};" class="label">${la.tasktype.type }</span>
									</c:if>
									${la.user.username }:${la.title }
								</span>
							</div>
							</c:forEach>
						</c:if>
						<c:if test="${fn:length(taskList) == 0 }" var="task">
							<div id="upcoming_tasks">
								<div class="alert alert-info"> 没有待办任务，或者已经完成了所有任务！ </div>
							</div>
						</c:if>
						
					</c:if>
					
					
					<!-- 已经完成的 -->
					<c:if test="${param.collection == 'completed' }">
						<legend>已完成的任务</legend>
						<c:if test="${fn:length(completeList) != 0 }">
							<c:forEach items="${completeList }" var="com">
								<div id="task_${com.id }" class="hover_container" style="margin:5px;padding:0 5px;position: relative;">
									<a class="icon icon-trash" title="Delete" rel="nofollow" data-remote="true" data-method="delete" onclick="deltask(this)" data-confirm="您确定要删除这个任务吗？" href="${basePath }/task/del?id=${com.id}" id="${com.id }"></a>
									<c:if test="${com.tasktype.type != null }">
										<span style="background:#${com.tasktype.color};border-radius: 3px 3px 3px 3px;padding:1px 5px;color:#fff">${com.tasktype.type }</span>
									</c:if>
									<span>${com.title }</span>
								</div>
							</c:forEach>
						</c:if>
					</c:if>
					
					</div>
					</div>
		
					<script type="text/javascript" charset="utf-8">
						$(document).ready(function() {
							$('span.task_hover').hover(function() {
								$(this).children().first().show();
							}, function() {
								$(this).children().first().hide();
							});
						});
					</script>
				</div>
		
				<script type="text/javascript">
					function donetask(obj){
						var user = $(obj).attr("alt");
						var id = $(obj).attr("value");
						if(confirm("你确定要标准"+user+"任务为完成吗？")){
							$.post("${basePath}/task/done",{"id":id},function(){
								$("#task_"+id).fadeOut();
							});
						}else{
							$("#task_done_"+id).attr("checked",false);
						}
					}
					
					//删除
					function deltask(obj){
						var id = $(obj).attr("id");
						$("#task_"+id).fadeOut();
					}
					
					
					$(document).ready(function(){
						ContactQuickShow.init();
						$("#context").val("tasks");
					});
				</script>
			</div>
		</div>
		</div>
		
		
		
		
		<div class="span4 sidebar">
			<div class="well">
				<a data-toggle="modal" href="${basePath }/task/add?filter=on&page=1&user_id=5888#taskModal">添加任务</a>
			</div>
	
			<div class="well">
				<div class="title">订阅您的日程安排</div>
				<p>
					您可以使用 Google Calendar, Apple iCal, Mozzila Calendar 等支持 iCalendar 格式的工具来
					<a href="${basePath }/task/calendar">订阅您的日程安排</a>。
				</p>
			</div>

		</div>
	</div>
</div>
	


</body></html>
